#include "SolidColorBackground.cuh"

using namespace OBR;

extern "C" __global__ void __miss__solid_color_background()
{
    SamplePRD *prd = getPRD();
    prd->hit = false;
    prd->inter.wo = prd->inter.wi;
    prd->inter.wo.t = prd->inter.wi.tmax;

    if (prd->ray_occlusion_test)
    {
        return;
    }

#ifdef DEBUG_SHADER
    if (prd->log)
    {
        printf("miss program launched\n");
    }
#endif

    MissData *sbt_record = reinterpret_cast<MissData *>(optixGetSbtDataPointer());
    SolidColorBackgroundData *data =
        reinterpret_cast<SolidColorBackgroundData *>(sbt_record->background_payload);
    prd->bg_radiance = data->radiance;

#ifdef DEBUG_SHADER
    if (prd->log)
    {
        printf("get bg radiance: ");
        data->radiance.print();
        printf("\n");
        printf("miss program ended\n");
    }
#endif
}